export default function (options) {
  var requestNum = 0;
  return new Promise((resolve, reject) => {
    requestNum++;
    var baseUrl = "https://api-hmugo-web.itheima.net/api/public/v1"
    wx.showLoading({
      title: '加载中',
      mask: true
    })
    wx.request({
      url: baseUrl + options.url,
      method: options.type || "get",
      data: options.data || {},
      success: resolve,
      fail: reject,
      // complete是无论成功还是失败都会执行的函数
      complete: () => {
        requestNum--
        if (requestNum == 0) {
          // 关闭数据加载图标
          wx.hideLoading()
        }
      }
    })
  })
}